Draft
Conversation
Upgrades stl-api to Zod v4 while maintaining backwards compatibility through
the zod/v3 compatibility layer. This approach avoids breaking changes for
consumers while enabling access to Zod v4 features.
Changes:
- Upgrade zod to ^4.0.0 in stainless, prisma, and ts-to-zod packages
- Upgrade zod-openapi to ^5.4.6 (from stainless fork)
- Use zod/v3 re-exports throughout for backwards compatibility
- Update module augmentations to target "zod/v3"
- Add type casts where zod/v3 and zod/v4 types interact
- Regenerate client test types
Note: zod-to-ts remains at v1 due to ESM/CJS interop issues with v2.
Co-Authored-By: Claude Code (User Settings, in: ${CLAUDE_PROJECT_DIR}) <noreply@anthropic.com>
- Update Zod from ^4.0.0 to ^4.3.6 in all packages
- Update Zod in demo package from v3 to v4
- Format generated-api-types.ts to fix prettier check
Co-Authored-By: Claude Code (User Settings, in: ${CLAUDE_PROJECT_DIR}) <noreply@anthropic.com>
cjquines
approved these changes
Jan 22, 2026
Member
cjquines
left a comment
There was a problem hiding this comment.
if tests pass it's probably fine
- Upgrade zod-to-ts from v1 to v2.0.0
- Add vitest deps.inline config for ESM/CJS interop with typescript
- Create comprehensive zod/v3 to zod v4 schema wrapper for zod-to-ts v2:
- Maps v3 _def.typeName to v4 _zod.def.type format
- Handles nested schemas (arrays, objects, optionals, unions, etc.)
- Maps native enums to regular enums for proper TypeScript generation
- Skips ZodNever catchall to avoid invalid [x: string]: never types
Co-Authored-By: Claude Code (User Settings, in: ${CLAUDE_PROJECT_DIR}) <noreply@anthropic.com>
Co-Authored-By: Claude Code (User Settings, in: ${CLAUDE_PROJECT_DIR}) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
zod/v3compatibility layer for backwards compatibilityzod/v3Changes
Technical Notes
zod/v3compatibility layer throughout to avoid breaking changes"zod/v3"instead of"zod"zod-to-ts v1 vs v2
zod-to-ts is kept at v1.2.0 because v2.0.0 has an ESM/CJS interop issue:
Root cause: zod-to-ts v2 is ESM and does
import { factory } from 'typescript'. Thetypescriptpackage is CJS-only, and Node.js ESM can't import named exports from CJS modules. This fails in vitest's ESM context.Workaround: v1.2.0 is CJS and works fine. It's compatible with Zod v4 at runtime (types need
as anycast).Future: When zod-to-ts fixes this (by using
import ts from 'typescript'; const { factory } = ts;), we can upgrade.Test plan
🤖 Generated with Claude Code